package cn.itcast.user.service.impl;


import cn.itcast.hmall.pojo.user.User;
import cn.itcast.user.mapper.UserMapper;
import cn.itcast.user.service.IUserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 用户表 服务实现类
 * </p>
 *
 * @author 哈纳桑
 * @since 2024-07-13
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService {
    @Override
    public void pay(Long money, Long id) {
        //查询用户信息
        User user = this.getById(id);
        //扣减余额
        user.setBalance(user.getBalance() - money);
        this.updateById(user);
    }
}
